package cn.jiakeyun.umeng_vertify_example

import android.graphics.Color
import android.os.Bundle
import android.os.PersistableBundle
import android.view.View
import cn.jiakeyun.umeng_vertify.UVerifyManagerConfig
import com.umeng.umverify.view.UMAuthUIConfig
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import me.jessyan.autosize.internal.CustomAdapt

//主工程
class MainActivity : FlutterActivity(), CustomAdapt {
    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
    }

    override fun getFlutterEngine(): FlutterEngine? {
        return super.getFlutterEngine()
    }

    override fun onDestroy() {
        super.onDestroy()
        ActivityManager.activity = null
    }

    override fun onStart() {
        super.onStart()


        val config = UMAuthUIConfig.Builder()
            .setNavHidden(true)
            .setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
            .setLogoImgDrawable(resources.getDrawable(R.mipmap.logo))
            .setSloganOffsetY(318)
            .setNumberColor(Color.WHITE)
            .setSloganTextColor(Color.parseColor("#ffD1D1D4"))
            .setNumberSize(26)
            .setSloganTextSize(12)
            .setLogoOffsetY(133)
            .setLogBtnOffsetY(374)
            .setNumFieldOffsetY(276)
            .setStatusBarColor(Color.TRANSPARENT)
            .setLogBtnHeight(50)
            .setLogBtnTextSize(17)
            .setLogBtnBackgroundDrawable(resources.getDrawable(R.drawable.login_bg))
            .setSwitchAccHidden(true)
            .setPrivacyOffsetY_B(30)
            .setSwitchAccTextColor(Color.parseColor("#99ffffff"))
            .setVendorPrivacyPrefix("《")
            .setVendorPrivacySuffix("》")
            .setProtocolAction("cn.jiakeyun.umeng_vertify_example.protocolWeb")
            .setWebViewStatusBarColor(Color.TRANSPARENT)
            .setPrivacyTextSize(12)
            .setAppPrivacyOne("《用户服务协议》", "http://www.baidu.com")
            .setAppPrivacyTwo("《隐私政策》", "http://originyyt.jiake365.com/doc.html")
            .setAppPrivacyColor(Color.WHITE, Color.WHITE)
            .create()
        UVerifyManagerConfig.initDelete(ViewDelegate())
            .initUiConfigure(config)
            .initLayoutId(R.layout.test_view)
    }

    override fun isBaseOnWidth(): Boolean = true

    override fun getSizeInDp(): Float = 375f
}
